﻿using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DevSamPle.FormPlugin
{
    [Description("【表单插件】OnBeforeWebApiOperation 对接口json进行干预"), HotUpdate]
    public class CustOnBeforeWebApiOperation : AbstractDynamicFormPlugIn
    {
        public override void OnBeforeWebApiOperation(AfterWebApiOperationArgs e)
        {
            base.OnBeforeWebApiOperation(e);
            var jsonStr = e.WebContext.RequestDTO;
            var js = JSONObject.Parse(jsonStr.ToString());
            Dictionary<string, object> dic = js.JSONToDictionary();

            Dictionary<string, object> model = dic.RKGet("Model") as Dictionary<string, object>;
            var fTreeEntity = model.RKGet("FTreeEntity");
            //var dictree = JsonConvert.DeserializeObject<Dictionary<string, object>>(fTreeEntity.ToString());
            //var model = js["Model"];
            //var modelJs = JSONObject.Parse(model.ToString());
            //var tree = modelJs["FTreeEntity"];
            //var treeJs = JsonConvert.SerializeObject(tree);
            //JObject trJob = JObject.Parse(treeJs);
            //var FRoutingId = trJob["FRoutingId"];
        }

    }
}
